// pages/daka/daka.js
import { client } from '../../request/index.js'

Page({
  data: {
    imgIp: getApp().globalData.imgIp,
    gpList: [
      {
        id: 0,
        value: 10,
        lightImg: '/1604509651982.png',
        darkImg: '/1604565820927.png',
        text: '光盘菜鸟',
      },
      {
        id: 1,
        value: 20,
        lightImg: '/1604509672382.png',
        darkImg: '/1604565836057.png',
        text: '光盘跟班',
      },
      {
        id: 2,
        value: 80,
        lightImg: '/1604509692965.png',
        darkImg: '/1604565848340.png',
        text: '光盘先锋',
      },
      {
        id: 3,
        value: 200,
        lightImg: '/1604509707773.png',
        darkImg: '/1604565857306.png',
        text: '光盘担当',
      },
      {
        id: 4,
        value: 400,
        lightImg: '/1604509724936.png',
        darkImg: '/1604565869105.png',
        text: '光盘标兵',
      },
      {
        id: 5,
        value: 600,
        lightImg: '/1604561656843.png',
        darkImg: '/1604565890367.png',
        text: '光盘达人',
      },
      {
        id: 6,
        value: 800,
        lightImg: '/1604509742258.png',
        darkImg: '/1604565898608.png',
        text: '光盘代言',
      },
      {
        id: 7,
        value: 1000,
        lightImg: '/1604561671197.png',
        darkImg: '/1604565908809.png',
        text: '光盘大师',
      },
    ],
    jzList: [
      {
        id: 0,
        value: 10,
        lightImg: '/1604566095788.png',
        darkImg: '/1604566105559.png',
        text: '爱的付出',
      },
      {
        id: 1,
        value: 20,
        lightImg: '/1604566125543.png',
        darkImg: '/1604566139893.png',
        text: '爱的守护',
      },
      {
        id: 2,
        value: 80,
        lightImg: '/1604566149437.png',
        darkImg: '/1604566158971.png',
        text: '爱的聚集',
      },
      {
        id: 3,
        value: 200,
        lightImg: '/1604566172508.png',
        darkImg: '/1604566182321.png',
        text: '爱的光芒',
      },
      {
        id: 4,
        value: 400,
        lightImg: '/1604566188568.png',
        darkImg: '/1604566213561.png',
        text: '奉献之心',
      },
      {
        id: 5,
        value: 600,
        lightImg: '/1604566222906.png',
        darkImg: '/1604566231055.png',
        text: '热善之心',
      },
      {
        id: 6,
        value: 800,
        lightImg: '/1604566244967.png',
        darkImg: '/1604566260245.png',
        text: '仁者之心',
      },
      {
        id: 7,
        value: 1000,
        lightImg: '/1604566265319.png',
        darkImg: '/1604566277441.png',
        text: '永恒之心',
      },
    ],
    clock_times: 0,
    dt_aCoin: 0,
  },

  changeYL: function () {
    this.setData({
      showModal: true,
    })
  },

  hideModal: function () {
    this.setData({
      showModal: false,
    })
  },
  // 获取打卡次数
  async getDaka() {
    const mapData = await client({
      url: '/account-log/clocklist',
    })
    console.log('打卡次数:', mapData)
    if (mapData.data.code == 888 || mapData.data.code == 500) {
      this.setData({
        clock_times: 0,
      })
    } else {
      this.setData({
        clock_times: mapData.data.data.length,
      })
    }
  },
  // 获取助力爱币
  async getACoin() {
    const mapData = await client({
      url: '/donate/donateaccount',
      data: {
        id: getApp().globalData.userId,
      },
    })
    console.log('助力爱币:', mapData)
    if (mapData.data.code === 200 && mapData.data.data) {
      this.setData({
        dt_aCoin: mapData.data.data,
      })
    }
  },
  onLoad(options) {
    this.getACoin()
    this.getDaka()
  },
})
